package com.lee.starter.response;

import com.lee.starter.response.constant.ResultCodeConstants;
import lombok.Data;

import java.io.Serializable;

/**
 * @author lee
 * @since 2019-11-22
 */
@Data
public class Result implements Serializable {

    /**
     * 结果码
     */
    private Integer code;

    /**
     * 结果信息
     */
    private String msg;

    /**
     * 返回数据
     */
    private Object data;

    public Result(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static Result success(Object data) {
        return new Result(ResultCodeConstants.SUCCESS, null, data);
    }

    public static Result error(int code, String msg) {
        return new Result(code, msg, null);
    }
}
